console.log(data);
var arrs = data.json.keywordAreas;
var leftnav = document.getElementById("leftnav");
var cat_list = document.getElementById("cat_list");
for(var i=0;i<arrs.length;i++){
    var a = arrs[i];
    var navLi = document.createElement("div");
    navLi.index  = i;
    navLi.onclick = function(){

        loadCatData(this.index);

        clearNavLiClassName();

        this.className = "div_active";

    };

    if(i==0){
        navLi.className = "div_active";
    }
    navLi.innerHTML = a.areaName;
    leftnav.appendChild(navLi);
}


function  clearNavLiClassName(){
    var divs = leftnav.getElementsByTagName("div");
    for(var i=0;i<divs.length;i++){
        divs[i].className = "";
    }
}


loadCatData(0);
function loadCatData(num){
    cat_list.innerHTML = "";
    var arrs2 = arrs[num].level1words;
    for(var j=0;j<arrs2.length;j++){
        var a2 = arrs2[j];
        var navLi = document.createElement("div");
        navLi.innerHTML = a2.keyword;
        navLi.style.fontWeight = "700";
        navLi.style.fontSize = "18px";
        cat_list.appendChild(navLi);
        var smallcatList = document.createElement("div");
        smallcatList.className = "smallcatList clearfix";
        var arrs3 = a2.level2words;
        for(var k=0;k<arrs3.length;k++){
            var a3 = arrs3[k];
            var catDiv = document.createElement("div");
            catDiv.className = "cat fl";
            catDiv.style.width = "30%";
            var imageDiv = document.createElement("img");
            imageDiv.src = "http:"+a3.imageUrl;
            imageDiv.style.width = "100%";
            var txtDiv = document.createElement("div");
            txtDiv.innerHTML = a3.keyword;

            txtDiv.onclick = function(){
                location = 'https://so.m.jd.com/ware/search.action?keyword='+this.innerHTML
                    +'&searchFrom=category';

            };
            catDiv.appendChild(imageDiv);
            catDiv.appendChild(txtDiv);
            smallcatList.appendChild(catDiv);
        }
        cat_list.appendChild(smallcatList);
    }
}


